package com.wsj.a.collapsingdemo.ui;

import android.content.Intent;
import android.databinding.DataBindingUtil;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

import com.umeng.socialize.bean.SHARE_MEDIA;
import com.wsj.a.collapsingdemo.R;
import com.wsj.a.collapsingdemo.callback.LoginCallback;
import com.wsj.a.collapsingdemo.databinding.ActivityLoginBinding;
import com.wsj.a.collapsingdemo.entity.QQUserInfo;
import com.wsj.a.collapsingdemo.entity.User;
import com.wsj.a.collapsingdemo.entity.WBUserInfo;
import com.wsj.a.collapsingdemo.entity.WXUserInfo;
import com.wsj.a.collapsingdemo.presenter.ThirdLoginPresenter;
import com.wsj.a.collapsingdemo.utils.Logger;

public class LoginActivity extends AppCompatActivity implements LoginCallback,ThirdLoginPresenter.OnLoginSuccessListener{

    private ActivityLoginBinding mBinding;
    private ThirdLoginPresenter thirdLoginPresenter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mBinding = DataBindingUtil.setContentView(LoginActivity.this,R.layout.activity_login);
        mBinding.setOnClick(this);
        thirdLoginPresenter = new ThirdLoginPresenter(LoginActivity.this,this,this);
    }

    //微博登录
    public void onSinaLogin(View view){
       thirdLoginPresenter.loginWB();
    }

    //QQ登录
    public void onQQLogin(View view){
       thirdLoginPresenter.loginQQ();
    }

    //微信登录
    public void onWechatLogin(View view){
       thirdLoginPresenter.loginWX();
    }

    @Override
    public void loginCancel(SHARE_MEDIA share_media) {

    }

    @Override
    public void loginError(SHARE_MEDIA share_media) {

    }

    @Override
    public void loginSuccess(User userInfo, SHARE_MEDIA share_media) {

    }

    @Override
    public void loginLoading() {

    }

    @Override
    public void onTencentQQ(QQUserInfo userInfo) {
       Logger.d("userInfo--->"+userInfo.toString());
       //获取到QQ登录信息

    }

    @Override
    public void onWeChat(WXUserInfo userInfo) {
        Logger.d("onWeChat--->"+userInfo.toString());
    }

    @Override
    public void onSINA(WBUserInfo userInfo) {
        Logger.d("WBUserInfo--->"+userInfo.toString());
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        thirdLoginPresenter.onActivityResult(requestCode,resultCode,data);
    }
}
